home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
PredatorPrey
/
calc_inits.c
< prev
next >
Wrap
Text File
|
1996-06-22
|
36KB
|
1,356 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
/* */
/* Prototype HP15C Calculator */
/* James C. Ullrey */
/* INRESCO */
/* © 1990 */
/* Version 13.97a */
/* */
/* INITS SEGMENT */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
/*****************************************************************/
/* I N C L U D E S
/*****************************************************************/
#ifndef __C14__
#include "PredatorPrey.h"
#endif
#include "create_prey.h"
#include "Globals.h"
#ifndef __RED__
#include "ResourceDefs.h"
#endif
#include "EventLoop.h"
#include "FileM.h"
#ifndef __CIN__
#include "calc_inits.h"
#endif
#include <Quickdraw.h>
/*#include "calc_prog_list.h"*/
#include <LowMem.h>
#include <OSUtils.h>
#include <Traps.h>
#include "DialogAids.h"
#include "calc_update.h"
//#include <SysEqu.h>
#define OKButton 1
#define CancelButton 2
#define Field4 4
#define Field6 6
#define Field8 8
#define PreRegister 10
/********************************************************************
/* G L O B A L V A R I A B L E D E C L A R A T I O N S
/********************************************************************/
extern Str255 bufferOne;
extern Str255 bufferTwo;
extern Str255 bufferTwe;
extern long gState;
extern long gsState;
extern long sto;
extern long rcl;
/*extern long gNewNum;*/
/*extern long canClear;*/
extern long gRoll;
extern long wait;
extern long gFlag;
extern long fFlag;
extern long sWait;
extern long rWait;
extern long lblWait;
extern long plus;
extern long minus;
extern long timesF;
extern long divide;
extern long gDot;
/*extern long rsFlag;*/
extern long gDigits;
/*extern long runMode;*/
/*extern long gsbWait;*/
extern long gtoWait;
extern Cursor fingerCursor;
extern Cursor questCursor;
extern Boolean useColor[7];
extern double_t thisIsFucked;
extern Point theNoColorPoint;
extern Point theTmNoColorPoint;
extern WindowPtr gMy_windows[];
extern Ptr gPre_allocated_block;
extern short gWindow_count;
extern Rect gArrow_box;
extern Rect gCircle_box;
extern Rect gSquare_box;
extern Rect gCube_box;
extern Rect gHouse_box;
extern Rect gBackGrnd_box;
extern Rect gPalette_frame;
extern Rect gRotation_frame;
extern Rect gMovement_frame;
extern Rect gPlaneControl_frame;
extern Rect gXrotation_box;
extern Rect gYrotation_box;
extern Rect gZrotation_box;
extern Rect gNegXrotation_box;
extern Rect gNegYrotation_box;
extern Rect gNegZrotation_box;
extern Rect gXrot_text_box;
extern Rect gYrot_text_box;
extern Rect gZrot_text_box;
extern Rect gRot_OK_box;
extern Rect gRot_Cancel_box;
extern Rect gDoManyRotation_box;
extern Rect gDoRotateLeft_box;
extern Rect gDoRotateRight_box;
extern Rect gDoRotateUp_box;
extern Rect gDoRotateDown_box;
extern Rect gDoMoveIn_box;
extern Rect gDoMoveOut_box;
extern Rect gDoPitchUp_box;
extern Rect gDoPitchDn_box;
extern Rect gDoYawLft_box;
extern Rect gDoYawRt_box;
extern Rect gDoBankLft_box;
extern Rect gDoBankRt_box;
extern Rect gStretch_frame;
extern Rect gXstretch_box;
extern Rect gYstretch_box;
extern Rect gZstretch_box;
extern Rect gNegXstretch_box;
extern Rect gNegYstretch_box;
extern Rect gNegZstretch_box;
extern Rect gXstr_text_box;
extern Rect gYstr_text_box;
extern Rect gZstr_text_box;
extern Rect gStr_OK_box;
extern Rect gStr_Cancel_box;
extern Boolean scrapDirty;
/*EventRecord curEvent;*/
/*WindowPtr curWindow;*/
extern WinInfoPtr cur;
extern WinInfoRec noCur;
extern Boolean preRegistered;
int defaultFont,defaultFontSize;
extern short kNumMyHelpItems;
extern WindowPtr lastPtr;
/*****************************************************************/
/* P R O T O T Y P E S
/*****************************************************************/
void InitFileMD (void);
void InitFileMP (void);
// Boolean trap_available (short trap_number,
// unsigned char trap_type);
Boolean trap_available (short trap_number,
TrapType trap_type);
Boolean WNE_is_implemented (void);
Boolean GetEnvir (short *vRef);
WindowPtr make_circle_window (short selector);
void SetInfo (WindowPtr window);
void UpdateMainWindow (void);
void DrawClippedGrow ( short x,
short y
);
Boolean GetShare (ShareRec *Share);
static Handle GetItemHandle (short itemNr);
//extern void DoPreReg (short n,short m);
/*****************************************************************/
/*****************************************************************/
/*
/* R O U T I N E S
/*
/*****************************************************************/
/*****************************************************************/
void inits_seg() {} /* for reference in "UnloadSeg()" calls */
/*****************************************************************/
/* I N I T R O M - Initialize ROM Managers.
/*****************************************************************/
void init_ROM()
{
/******************* Memory Manager "initializations" ******************/
/* These calls really SHOULD be done by every application. */
DoSetStackSize();
MaxApplZone(); /* grow the heap to its maximum size */
MoreMasters(); /* create more master pointers */
MoreMasters(); /* create more master pointers */
MoreMasters(); /* create more master pointers */
MoreMasters(); /* create more master pointers */
MoreMasters(); /* create more master pointers */
MoreMasters(); /* create more master pointers */
/******************* ROM Manager initializations ******************/
InitGraf( &qd.thePort ); /* Initializes QuickDraw */
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs( NIL_POINTER );
/**************** Event Loop and Cursor initialization ******************/
FlushEvents(everyEvent,REMOVE_ALL_EVENTS); /* clear the Event queue of all events */
InitCursor(); /* set the cursor to arrow instead of clock */
defaultFont = monaco;
defaultFontSize = 9;
InitFileMD ();
InitFileMP ();
InitFileMB ();
} /* end of init_ROM */
/********************** GetEnvir ************************/
Boolean GetEnvir( short *vRef )
{
OSErr status;
SysEnvRec SysEnvData;
/*GDHandle theGD;*/
GDHandle theGD[7];
short result;
short gdDevType[7];
short i;
//for(i = 0;i <= 6; i++)
//{
// useColor[i] = 1;
// /*gdDevType[i] = 1;*/
//}
status = SysEnvirons( SYS_VERSION, &SysEnvData ); /*SysEnvirons, V-5*/
if (( status != noErr ) || ( SysEnvData.systemVersion < 0x0600 ))
{
StopAlert( BAD_SYS_ALERT, NIL_POINTER );
result = FALSE;
}
else
{
*vRef = SysEnvData.sysVRefNum;
result = TRUE;
}
if ((SysEnvData.machineType > 0) && SysEnvData.hasColorQD)
{
theGD[0] = GetMainDevice();
/* SetDeviceAttribute(theGD[0],0,1); */
/* sys 6 */
useColor[0] = TestDeviceAttribute (theGD[0], 0);
i = 0;
do
{
theGD[i+1] = GetNextDevice(theGD[i]);
if(theGD[i+1] != NIL)
useColor[i+1] = TestDeviceAttribute (theGD[i+1], 0);
i++;
}
while(theGD[i] != NIL);
}
return( result);
} /* NOTE: "#define SYS_VERSION 1" from calculator.h */
/********************** MenuBarInit ************************/
void MenuBarInit()
{
Handle myMenuBar;
Boolean checkIt = FALSE;
OSErr myErr;
MenuHandle myHelpMenuHandle;
Str255 itemString;
myMenuBar = GetNewMBar( BASE_RES_ID );
SetMenuBar( myMenuBar );
gAppleMenu = GetMHandle( APPLE_MENU_ID );
AddResMenu( gAppleMenu, 'DRVR' );
gFileMenu = GetMHandle( FILE_MENU_ID ); /* gFileMenu is a global defined in Calculator.h */
gEditMenu = GetMHandle( EDIT_MENU_ID );
//gWindowMenu = GetMHandle( WINDOW_MENU_ID );
//gProgMenu = GetMHandle( PROGRAM_MENU_ID );
gGraphMenu = GetMHandle( GRAPHICS_MENU_ID ); /* 405 */
myErr = HMGetHelpMenuHandle(&myHelpMenuHandle);
if(myErr == noErr)
{
if(myHelpMenuHandle != nil)
{
kNumMyHelpItems = CountMItems(myHelpMenuHandle);
GetIndString(itemString, kMyStrings, kCalcHelp);
AppendMenu(myHelpMenuHandle, itemString);
GetIndString(itemString, kMyStrings, kAltCalcHelp);
AppendMenu(myHelpMenuHandle, itemString);
}
}
gGrafType = GetMenu( 100 );
InsertMenu( gGrafType, -1 );
gDorkMenu = GetMHandle( DORK_MENU_ID );
DisableItem(GetMHandle(FILE_MENU_ID), 1);
//DisableItem(GetMHandle(FILE_MENU_ID), 6);
//DisableItem(GetMHandle(FILE_MENU_ID), 7);
//DisableItem(GetMHandle(FILE_MENU_ID), 12);
/*DisableItem(GetMHandle(WINDOW_MENU_ID), 1);*/
DrawMenuBar();
}
/********************** WindowInit ************************/
void WindowInit()
{
short n;
Str255 pFName = "\p";
Str255 qFName = "\p";
short vRefNum = 0;
short pRefNum = 0;
short qRefNum = 0;
/*** Globals initializations ***/
/* MY_WINDOW_MAX = 5 */
for(n = 0; n <= MY_WINDOW_MAX; n++) /* array is MAX+1 in size */
gMy_windows[n] = NIL; /* clear window pointers */
SetRect(&gArrow_box, -1, -1, 31, 31); /* Set up palette boxes' borders */
SetRect(&gCircle_box, -1, 29, 31, 61);
SetRect(&gSquare_box, -1, 59, 31, 91);
SetRect(&gCube_box, -1, 89, 31, 121);
SetRect(&gHouse_box, -1, 119, 31, 151);
SetRect(&gBackGrnd_box, -1, 149, 31, 181);
SetRect(&gPalette_frame, -1, -1, 31, 181);
/********************** L, T, R, B *******/
SetRect(&gXrotation_box, -1, -1, 31, 31);
SetRect(&gYrotation_box, -1, 29, 31, 61);
SetRect(&gZrotation_box, -1, 59, 31, 91);
SetRect(&gNegXrotation_box, 29, -1, 61, 31);
SetRect(&gNegYrotation_box, 29, 29, 61, 61);
SetRect(&gNegZrotation_box, 29, 59, 61, 91);
SetRect(&gDoManyRotation_box,89,29,121,61);
SetRect(&gMovement_frame,-1,89,61,181);
SetRect(&gPlaneControl_frame,59,89,121,181);
SetRect(&gDoRotateLeft_box,-1,89,31,121);
SetRect(&gDoRotateRight_box,29,89,61,121);
SetRect(&gDoRotateUp_box,-1,119,31,151);
SetRect(&gDoRotateDown_box,29,119,61,151);
SetRect(&gDoMoveIn_box,-1,149,31,181);
SetRect(&gDoMoveOut_box,29,149,61,181);
SetRect(&gDoPitchUp_box,59,89,91,121);
SetRect(&gDoPitchDn_box,89,89,121,121);
SetRect(&gDoYawLft_box,59,119,91,151);
SetRect(&gDoYawRt_box,89,119,121,151);
SetRect(&gDoBankLft_box,59,149,91,181);
SetRect(&gDoBankRt_box,89,149,121,181);
SetRect(&gXrot_text_box, 121, 6, 181, 20);
SetRect(&gYrot_text_box, 121, 38, 181, 52);
SetRect(&gZrot_text_box, 121, 70, 181, 94);
SetRect(&gRot_OK_box, 241, 6, 291, 20);
SetRect(&gRot_Cancel_box, 241, 38, 291, 52);
SetRect(&gRotation_frame, -1, -1, 61, 91);
SetRect(&gXstretch_box, -1, -1, 31, 31);
SetRect(&gYstretch_box, -1, 29, 31, 61);
SetRect(&gZstretch_box, -1, 59, 31, 91);
SetRect(&gNegXstretch_box, 29, -1, 61, 31);
SetRect(&gNegYstretch_box, 29, 29, 61, 61);
SetRect(&gNegZstretch_box, 29, 59, 61, 91);
SetRect(&gXstr_text_box, 121, 6, 181, 20);
SetRect(&gYstr_text_box, 121, 38, 181, 52);
SetRect(&gZstr_text_box, 121, 70, 181, 94);
SetRect(&gStr_OK_box, 241, 6, 291, 20);
SetRect(&gStr_Cancel_box, 241, 38, 291, 52);
SetRect(&gStretch_frame, -1, -1, 61, 91);
/**************** Get room for a WindowPtr in low heap ********************/
gPre_allocated_block = NewPtr(sizeof(CWindowRecord));
if(gPre_allocated_block == NIL)
{
#ifdef powerc
StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_MEM, NIL);
#endif /* powerc */
ExitToShell();
}
//SetPort( gCalcWindow );
//SetNewInfo(gCalcWindow);
cur->pFileNum = pRefNum; /* program file refNum */
cur->qFileNum = qRefNum; /* data file refNum */
cur->volNum = vRefNum;
cur->pDirty = false;
cur->qDirty = false;
cur->pFilename = NewString (pFName);
cur->qFilename = NewString (qFName);
cur->windowKind = WMainWindow;
((WindowPeek) curWindow)->windowKind = userKind + WMainWindow;
cur->witlHandle = GetResource ('Witl', MainWindowID);
cur->wictHandle = GetResource ('Wict', MainWindowID);
cur->text = nil;
//ShowWindow( gCalcWindow );
}
/********************** LoadPicture ************************/
void LoadPicture()
{
gSkullPicture30 = GetPicture( BASE_RES_ID+12 );
gSkullPicture35 = GetPicture( BASE_RES_ID+13 );
gSkullPicture40 = GetPicture( BASE_RES_ID+14 );
gSkullPicture45 = GetPicture( BASE_RES_ID+15 );
gSkullPicture50 = GetPicture( BASE_RES_ID+16 );
gSkullPicture55 = GetPicture( BASE_RES_ID+17 );
gSkullPicture60 = GetPicture( BASE_RES_ID+18 );
gSkullPicture65 = GetPicture( BASE_RES_ID+19 );
gSkullPicture70 = GetPicture( BASE_RES_ID+20 );
gSkullPicture75 = GetPicture( BASE_RES_ID+21 );
gSkullPicture80 = GetPicture( BASE_RES_ID+22 );
gSkullPicture85 = GetPicture( BASE_RES_ID+23 );
gSkullPicture90 = GetPicture( BASE_RES_ID+24 );
gSkullPicture95 = GetPicture( BASE_RES_ID+25 );
gSkullPicture100 = GetPicture( BASE_RES_ID+26 );
}
/*********************** SetUpCursors *************************/
void SetUpCursors(void)
{
CursHandle hCurs;
hCurs = GetCursor(BASE_RES_ID);
fingerCursor = **hCurs;
hCurs = GetCursor(BASE_RES_ID+1);
questCursor = **hCurs;
}
/********************** SetUpDragRect ************************/
void SetUpDragRect()
{
RgnHandle theRgn; /* see: RectRgn, DiffRgn */
/* NewRgn,EmptyRgn */
theRgn = GetGrayRgn();
gDragRect = (**theRgn).rgnBBox; /* Rect gDragRect; */
gNoColorDragRect = qd.screenBits.bounds;
/*gNoColorDragRect.left += DRAG_THRESHOLD;*/
/*gNoColorDragRect.right -= DRAG_THRESHOLD;*/
/*gNoColorDragRect.bottom -= DRAG_THRESHOLD;*/
}
/************************************************************************************/
/* RectRgn( theRgn, &theRect ); converts the rgn to a rect IV I-183 */
/* InvalRgn( badRgn ); forces an update of a rgn, in local window coords */
/* DiffRgn( srcRgnA, srcRgnB, destRgn ); the difference of rgnA & rgnB -> dest */
/* SectRgn( srcRgnA, srcRgnB, destRgn ); the intersection of rgnA & rgnB -> dest */
/* IM I-184 */
/* if( EmptyRgn( theRgn ) ) { after a SectRgn call, test for no intersection */
/* if( RectInRgn( &theRect, theRgn ) ) { check if a rect intersects a rgn */
/* XorRgn( srcRgnA, srcRgnB, destRgn ); find the union, less intersect of 2 rgns */
/* visRgn RgnHandle:hndl to a rect region coincident with screenBits.bounds */
/* portRect Rect screenBits.bounds */
/* GDevice structure - has essential info */
/* BitMap portBits.bounds of grafPort */
/* RectInRgn IM I-185 */
/* SectRect IM I-175 */
/************************************************************************************/
/********************** SetUpButtonRect ************************/
void SetUpButtonRect()
{
/* SetRect( theRect, rLeft, rTop, rRight, rBottom); */
SetRect( &gSkullRect30,354,20,402,63 );
SetRect( &gSkullRect35,329,19,404,79 );
SetRect( &gSkullRect40,304,18,406,95 );
SetRect( &gSkullRect45,279,17,408,111 );
SetRect( &gSkullRect50,254,15,410,127 );
SetRect( &gSkullRect55,229,13,412,143 );
SetRect( &gSkullRect60,203,11,415,160 );
SetRect( &gSkullRect65,177,9,418,177 );
SetRect( &gSkullRect70,151,7,421,194 );
SetRect( &gSkullRect75,125,5,424,211 );
SetRect( &gSkullRect80,100,4,427,228 );
SetRect( &gSkullRect85,75,3,429,244 );
SetRect( &gSkullRect90,50,2,431,260 );
SetRect( &gSkullRect95,25,1,433,276 );
SetRect( &gSkullRect100,0,0,435,295 );
SetRect( &gDisplayRect, 50,23,333,54 );
SetRect( &gHPRect, 357,23,399,46 );
SetRect( &g1499Rect, 357,50,399,60 );
SetPt(&theNoColorPoint,BTN_LFT+91,BTN_TOP+157);
/*theNoColorPoint->h = BTN_LFT+91;*/
/*theNoColorPoint->v = BTN_TOP+157;*/
} /* * end of SetUpButtonRect * */
/********************* SetUpNewButtonRect **********************/
void SetUpNewButtonRect()
{
/* SetRect( theRect, rLeft, rTop, rRight, rBottom); */
SetPt(&theTmNoColorPoint,NBTN_LFT+80,NBTN_TOP+150);
/* SetRect( theRect, rLeft, rTop, rRight, rBottom); */
} /* * end of SetUpNewButtonRect * */
void SetUpHelpRect(void)
{
/* SetRect( theRect, rLeft, rTop, rRight, rBottom); */
/* SetRect( theRect, rLeft, rTop, rRight, rBottom); */
}
/*********************** CenterWindow ****************************/
/*****************************************************************/
void CenterWindow( WindowPtr wptr )
/* Calculates left, top position of center & moves window */
{
short scrW, scrV;
Rect scrRect;
Point where;
WinRect( wptr, &scrRect ); // Returns the window global coordinates in scrRect
scrW = qd.screenBits.bounds.right - qd.screenBits.bounds.left; // Calculates screen width
scrV = ( qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ) - GetMBarHeight(); // Calculates screen height
where.v = ( scrV - ( scrRect.bottom - scrRect.top ) )/2; // Calculates top left vert coordinate
where.h = ( scrW - ( scrRect.right - scrRect.left ) )/2; // Calculates the top left horiz coordinate
MoveWindow( wptr, where.h, where.v, false ); // Moves window to new location
}
/*****************************************************************/
/*********************** splashScreen ****************************/
/*****************************************************************/
void SplashScreen (void)
{
WindowPtr dPtr;
GrafPtr oldPort;
long ticktime;
short iType;
short itemHit;
Handle h;
PicHandle hh;
Rect box;
Boolean notDone = TRUE;
ProcPtr myFilter;
if ( (dPtr = GetNewDialog(SPLASH_SCREEN, NIL_POINTER, (WindowPtr)MOVE_TO_FRONT) )
!= NIL_POINTER )
{
GetPort(&oldPort );
/*****************************************************************/
GetDItem(dPtr,2,&iType,&h,&box);
if(useColor[0])
{
SetDItem(dPtr,2,iType,h,&box);
}
else
{
hh = GetPicture(410);
SetDItem(dPtr,2,iType,(Handle)hh,&box);
}
/*****************************************************************/
CenterWindow( dPtr );
ShowHide( dPtr,TRUE ); /* Make window visible if invisible */
SetPort( dPtr );
DrawDialog(dPtr);
Delay (60L, &ticktime); /* wait 1 second ( 60 TICKS ) */
DisposDialog (dPtr); /* Remove window from memory */
SetPort( oldPort );
/* DoAboutText( dPtr );*/
}
else
{
SysBeep (1); // Sound the alarm
ExitToShell (); /* probably can't open resource fork! */
}
}
static void DoShare(void)
{
ShareRec ShareInfo;
register ShareRecPtr info;
short i,j;
info = &ShareInfo;
info->Field4Text [0] = 0;
info->Field6Text [0] = 0;
info->Field8Text [0] = 0;
if(GetShare (&ShareInfo))
{
/* use ShareInfo */
if(info->Field4Text [0] != 0)
{
i = info->Field4Text [0];
for(j = 0;j<=i;j++)
{
bufferOne[j] = info->Field4Text[j];
}
}
if(info->Field6Text [0] != 0)
{
i = info->Field6Text [0];
for(j = 0;j<=i;j++)
{
bufferTwo[j] = info->Field6Text[j];
}
}
if(info->Field8Text [0] != 0)
{
i = info->Field8Text [0];
for(j = 0;j<=i;j++)
{
bufferTwe[j] = info->Field8Text[j];
}
}
}
}
void DoTheShare (void)
{
DoShare();
}
Boolean GetShare(ShareRec *Share)
{
GrafPtr sOldPort;
DialogPtr shrPtr;
Boolean result;
Boolean done;
short itemNr;
short n,m;
register ShareRecPtr info;
ModalFilterUPP gMyStandardFilterProcUPP;
if((shrPtr = GetNewDialog(SHR_SCRN,NIL_PTR,(WindowPtr)MOVE_TO_FRONT) ) != NIL_PTR )
{
GetPort(&sOldPort );
SetPort( shrPtr );
info = Share;
SetDText (Field4, info->Field4Text);
SetDText (Field6, info->Field6Text);
SetDText (Field8, info->Field8Text);
CenterWindow( shrPtr ); /* this */
ShowHide( shrPtr,TRUE ); /* Make window visible if invisible */
OutlineButton (1);
DrawDialog(shrPtr);
gMyStandardFilterProcUPP = NewModalFilterProc(StandardFilter);
do
{
//ModalDialog(StandardFilter,&itemNr);
ModalDialog(gMyStandardFilterProcUPP,&itemNr);
switch (itemNr)
{
case OKButton:
result = true;
done = true;
break;
case CancelButton:
result = false;
done = true;
break;
case PreRegister:
/*****************************************************************/
/* n = info->Field4Text[0];*/
/* m = info->Field6Text[0];*/
/* DoPreReg(n,m);*/
/* SetDText (Field8, map.mem1name);*/
/*****************************************************************/
preRegistered = TRUE;
result = true;
break;
case Field4:
GetDText (itemNr, info->Field4Text);
break;
case Field6:
GetDText (itemNr, info->Field6Text);
break;
case Field8:
GetDText (itemNr, info->Field8Text);
break;
}
}
while((itemNr != 1) && (itemNr != 2) && (itemNr != 10));
DisposDialog (shrPtr); /* Remove window from memory */
SetPort( sOldPort );
return (result);
}
}
/*----------*/
/*void SetDText (short itemNr,
Str255 text)
{
Handle itemHandle;
itemHandle = GetItemHandle (itemNr);
SetIText (itemHandle, text);
}*/ /*SetDText*/
/*----------*/
/*void GetDText (short itemNr,
Str255 text)
{
Handle itemHandle;
itemHandle = GetItemHandle (itemNr);
GetIText (itemHandle, text);
} *//*GetDText*/
/*----------*/
static Handle GetItemHandle (short itemNr)
{
short itemType;
Handle itemHandle;
Rect itemRect;
GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
return (itemHandle);
} /*GetItemHandle*/
/*****************************************************************/
/********************** StandardFilter ***************************/
/*****************************************************************/
/*void OutlineButton (short itemNr)
{
Rect itemRect;
PenState savePen;
GetPenState (&savePen);
PenNormal ();
PenSize (3, 3);
itemRect = GetDRect (itemNr);
InsetRect (&itemRect, -4, -4);
FrameRoundRect (&itemRect, 16, 16);
SetPenState (&savePen);
}*/ /*OutlineButton*/
/*void DoUpdate ()*/
/*{*/
/* GrafPtr savePort;*/
/* WindowPtr saveWindow;*/
/* WindowPtr whichWindow;*/
/**/
/* GetPort (&savePort);*/
/* whichWindow = (WindowPtr) curEvent.message;*/
/* SetPort (whichWindow);*/
/* saveWindow = curWindow;*/
/* SetInfo (whichWindow);*/
/* BeginUpdate (whichWindow);*/
/* EraseRect (&(whichWindow->portRect));*/
/* DrawControls (whichWindow);*/
/* UpdateContent ();*/
/* EndUpdate (whichWindow);*/
/* SetInfo (saveWindow); */
/* SetPort (savePort);*/
/*}*/ /*DoUpdate*/
/*----------*/
/*Rect GetDRect (short itemNr)
{
short itemType;
Handle itemHandle;
Rect itemRect;
GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
return (itemRect);
}*/ /*GetDRect*/
/*void SetInfo (WindowPtr window)*/
/*{*/
/* WinInfoPtr infoPtr;*/
/**/
/* if (window != curWindow) {*/
/* curWindow = window;*/
/* if (curWindow != nil) {*/
/* infoPtr = (WinInfoPtr) GetWRefCon (curWindow);*/
/* cur = infoPtr;*/
/* } else {*/
/* cur = &noCur;*/
/* }*/
/* }*/
/*} /*SetInfo»*/
/*void UpdateContent (void)*/
/*{*/
/* switch (cur->windowKind) {*/
/* case WMainWindow:*/
/* UpdateMainWindow ();*/
/* break;*/
/* */
/* } /*switch»*/
/*} /*UpdateContent»*/
void UpdateMainWindow (void)
{
Rect bounds;
DrawClippedGrow (-15, -15);
} /*UpdateMainWindow*/
/*****************************************************************/
/******************** end of StandardFilter **********************/
/*****************************************************************/
/*pascal Boolean myFilter(DialogPtr shrPtr,EventRecord *event, short itemHit)*/
/*/*DialogPtr shrPtr;»*/
/*/*EventRecord *event;»*/
/*/*short itemHit;»*/
/*{*/
/* char key;*/
/* WindowPtr wizPtr;*/
/* GrafPtr wOldPort;*/
/* */
/* */
/* switch (event->what)*/
/* {*/
/* case nullEvent:*/
/* return FALSE;*/
/* break;*/
/* case keyDown:*/
/* case autoKey:*/
/* key = event->modifiers & charCodeMask;*/
/* if(event->modifiers & cmdKey)*/
/* if ((key == 87) || (key == 119))*/
/* {*/
/* if((wizPtr = GetNewDialog(WIZ_SCRN,NIL_PTR,(WindowPtr)MOVE_TO_FRONT) ) != NIL_PTR )*/
/* {*/
/* GetPort(&wOldPort );*/
/* CenterWindow( wizPtr );*/
/* ShowHide( wizPtr,TRUE ); /* Make window visible if invisible »*/
/* SetPort( wizPtr ); */
/* DrawDialog(wizPtr);*/
/* do*/
/* {*/
/* ModalDialog(NIL /* myFilter »,&itemHit);*/
/* }*/
/* while(itemHit != 5);*/
/* DisposDialog (wizPtr); /* Remove window from memory »*/
/* SetPort( wOldPort );*/
/* }*/
/* }*/
/* return FALSE;*/
/* default:*/
/* return FALSE;*/
/* }*/
/*}*/
/*****************************************************************/
/********************** trap_available ***************************/
/*****************************************************************/
/*
//Boolean trap_available(short trap_number,unsigned char trap_type)
Boolean trap_available(short trap_number,TrapType trap_type)
//short trap_number;
//unsigned char trap_type;
{
UniversalProcPtr Ntrap_address;
UniversalProcPtr trap_address;
Ntrap_address = NGetTrapAddress(trap_number, trap_type);
trap_address = GetTrapAddress(UNIMPLEMENTED);
//return(trap_address != GetTrapAddress(UNIMPLEMENTED) );
return(Ntrap_address != trap_address );
}*/ /* end of trap_available */
/*----------*/
/*Boolean TrapAvailable (short tNumber,
TrapType tType);
Boolean TrapAvailable (short tNumber,
TrapType tType)
{
return (NGetTrapAddress (tNumber, tType)
!= GetTrapAddress (_Unimplemented));
} *//*TrapAvailable*/
/*****************************************************************/
/****************** WNE_is_implemented ***************************/
/*****************************************************************/
Boolean WNE_is_implemented()
{
SysEnvRec theWorld;
unsigned char trap_type, tool_trap = 2;
SysEnvirons(1, &theWorld);
return( NGetTrapAddress( WNE_TRAP_NUM, ToolTrap ) !=
NGetTrapAddress( UNIMPL_TRAP_NUM, ToolTrap ) );
}
/*****************************************************************/
/*********************** GetFucked *******************************/
/*****************************************************************/
/************** Comes from "This is Fucked" **********************/
/*****************************************************************/
WindowPtr get_window(short selector) /* -----------------------------+ */
{
short n;
char window_number[21], local_str[255];
char *char_ptr, *str_ptr;
StringHandle title_hndl;
WObjsHandle w_objs_hndl;
WPObjsHandle wp_objs_hndl;
/*** Find available window pointer in our list ***/
n = 1;
while( (gMy_windows[n] != NIL) && (n <= MY_WINDOW_MAX + 1) ) n++;
if ( n > MY_WINDOW_MAX )
{
#ifdef powerc
StopAlert(OUT_OF_WNDWS, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_WNDWS, NIL);
#endif /* powerc */
return(NIL); /* when window not allocated */
}
/*** if there is room, create a window ***/
gMy_windows[n] = make_circle_window(selector); /* <--------------------+ */
/* return NIL if problem creating window */
if(gMy_windows[n] == NIL)
{
return(NIL);
}
gWindow_count++;
SetPort(gMy_windows[n]);
/*** Set up the window title ***/
local_str[0] = 0;
str_ptr = local_str;
title_hndl = (*(WindowPeek)gMy_windows[n]).titleHandle;
MoveHHi((Handle)title_hndl);
HLock((Handle)title_hndl);
char_ptr = (char *) (*title_hndl);
cat_strings(char_ptr, str_ptr, 255); /* cat_strings(source,destination,maximum) */
HUnlock((Handle)title_hndl);
str_ptr[str_ptr[0]+1] = ' ';
str_ptr[0]++;
window_number[0] = 0;
char_ptr = window_number; /* append the incremental window count */
NumToString(gWindow_count, (StringPtr)char_ptr);
cat_strings(char_ptr, str_ptr, 255); /* char_ptr is source,str_ptr is dest */
/* source is appended to dest */
SetWTitle(gMy_windows[n], (StringPtr)local_str);
/************* Set new window name in WObjs Record, fileName ************/
w_objs_hndl = (WObjsHandle)GetWRefCon(gMy_windows[n]);
HLock((Handle)w_objs_hndl);
(**w_objs_hndl).findFile.fName[0] = 0;
char_ptr = (char*)(&(**w_objs_hndl).findFile.fName[0]);
cat_strings(str_ptr, char_ptr, 63);
HUnlock((Handle)w_objs_hndl);
/*** Position the window on the screen ***/
MoveWindow(gMy_windows[n], qd.screenBits.bounds.left + (n*30),
qd.screenBits.bounds.top + GetMBarHeight() + 20 + (n*30), false);
return(gMy_windows[n]);
} /* end of get_window() */
/******************** get_rotation_box ***************************/
WindowPtr get_rotation_box()
{
WindowPtr wPtr = NIL;
WRObjsHandle wr_objs_hndl;
wPtr = GetNewWindow(ROTATION_BOX_ID,NIL, (WindowPtr) -1);
if(wPtr == NIL)
{
#ifdef powerc
StopAlert(NO_ROTATION_BOX, (UniversalProcPtr)NIL);
#else
StopAlert(NO_ROTATION_BOX, NIL);
#endif /* powerc */
return(NIL);
}
SetPort(wPtr);
wr_objs_hndl = (WRObjsHandle)NewHandle(sizeof(WRObjs));
if (wr_objs_hndl == NIL)
{
DisposeWindow(wPtr);
#ifdef powerc
StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_MEM, NIL);
#endif /* powerc */
return(FALSE);
}
SetWRefCon (wPtr, (long)wr_objs_hndl); /* set the handle into window record */
return(wPtr);
}
/***************** end of get_rotation_box ***********************/
/********************* get_stretch_box ***************************/
WindowPtr get_stretch_box()
{
WindowPtr wPtr = NIL;
WSObjsHandle ws_objs_hndl;
wPtr = GetNewWindow(STRETCH_BOX_ID,NIL, (WindowPtr) -1);
if(wPtr == NIL)
{
#ifdef powerc
StopAlert(NO_STRETCH_BOX, (UniversalProcPtr)NIL);
#else
StopAlert(NO_STRETCH_BOX, NIL);
#endif /* powerc */
return(NIL);
}
SetPort(wPtr);
ws_objs_hndl = (WSObjsHandle)NewHandle(sizeof(WSObjs));
if (ws_objs_hndl == NIL)
{
DisposeWindow(wPtr);
#ifdef powerc
StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_MEM, NIL);
#endif /* powerc */
return(FALSE);
}
SetWRefCon (wPtr, (long)ws_objs_hndl); /* set the handle into window record */
return(wPtr);
}
/***************** end of get_stretch_box ************************/
/******************* make_circle_window **************************/
WindowPtr make_circle_window(short selector)
{
short cntrl_max, i,n;
StringHandle str_hndl;
WindowPtr wPtr = NIL;
//WindowPtr lastPtr;
ControlHandle cntrl_hndl;
WObjsHandle w_objs_hndl;
WObjsHandle last_objs_hndl;
THPrint print_info_hndl;
OSErr printerDriverError;
short switcher;
if(selector == 3)
{
last_objs_hndl = (WObjsHandle)GetWRefCon(lastPtr);
}
wPtr = GetNewCWindow(WINDOW_ID, gPre_allocated_block, (WindowPtr) -1);
if(wPtr == NIL)
{
#ifdef powerc
StopAlert(OUT_OF_WNDWS, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_WNDWS, NIL);
#endif /* powerc */
return(NIL);
}
SetPort(wPtr);
gPre_allocated_block = NIL;
str_hndl = GetString(W_TITLE_ID);
HLock((Handle)str_hndl);
SetWTitle(wPtr, *str_hndl);
HUnlock((Handle)str_hndl);
w_objs_hndl = (WObjsHandle)NewHandle(sizeof(WObjs));
if (w_objs_hndl == NIL)
{
DisposeWindow(wPtr);
#ifdef powerc
StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);
#else
StopAlert(OUT_OF_MEM, NIL);
#endif /* powerc */
return(FALSE);
}
SetWRefCon (wPtr, (long)w_objs_hndl); /* set the handle into window record */
switch(selector)
{
case 1:
(**w_objs_hndl).paletteSetting = CIRCLE_OBJ;
(**w_objs_hndl).hasBackGround = FALSE;
(**w_objs_hndl).gXYZplane.x_point = 200;
(**w_objs_hndl).gXYZplane.y_point = 100;
(**w_objs_hndl).gXYZplane.z_point = 0;
(**w_objs_hndl).vPtNo = 0;
(**w_objs_hndl).xvPt = 300;
(**w_objs_hndl).yvPt = 200;
(**w_objs_hndl).focalLn = 50;
(**w_objs_hndl).focalPtNo = 7;
(**w_objs_hndl).isPrey = 0;
break;
case 2:
(**w_objs_hndl).paletteSetting = PLOT_OBJ;
(**w_objs_hndl).isPrey = 0;
break;
case 3:
//(**w_objs_hndl).paletteSetting = NO_OBJ;
(**w_objs_hndl).gXYZplane.x_point = 200;
(**w_objs_hndl).gXYZplane.y_point = 100;
(**w_objs_hndl).gXYZplane.z_point = 0;
(**w_objs_hndl).vPtNo = 0;
(**w_objs_hndl).xvPt = 300;
(**w_objs_hndl).yvPt = 200;
(**w_objs_hndl).focalLn = 50;
(**w_objs_hndl).focalPtNo = 7;
(**w_objs_hndl).isPrey = 1;
(**w_objs_hndl).paletteSetting = (**last_objs_hndl).paletteSetting;
for(i = 0;i < MAX_OBJECTS;i++)
{
//switcher = (**last_objs_hndl).object[i].type;
//switch(switcher)
//{
// case HOUSE_OBJ:
// case ARMD_HOUSE3_OBJ:
// case ARMD_HOUSE2_OBJ:
// case ARMD_HOUSE1_OBJ:
// (**w_objs_hndl).object[i]
// break;
// default:
(**w_objs_hndl).object[i] = (**last_objs_hndl).object[i];
// break;
//}
}
(**w_objs_hndl).isArmed = (**last_objs_hndl).isArmed;
(**w_objs_hndl).targets_left = (**last_objs_hndl).targets_left;
(**w_objs_hndl).armament_type = (**last_objs_hndl).armament_type;
(**w_objs_hndl).arms_selected = (**last_objs_hndl).arms_selected;
(**w_objs_hndl).hasTargets = (**last_objs_hndl).hasTargets;
(**w_objs_hndl).hasBackGround = (**last_objs_hndl).hasBackGround;
break;
}
(**w_objs_hndl).vDocLimit = DOC_LENGTH;
(**w_objs_hndl).hDocLimit = DOC_WIDTH;
(**w_objs_hndl).scrollAmount.v = 0;
(**w_objs_hndl).scrollAmount.h = 0;
(**w_objs_hndl).hasRealName = FALSE;
(**w_objs_hndl).findFile.good = 0;
(**w_objs_hndl).findFile.vRefNum = 0;
(**w_objs_hndl).findFile.fName[0] = 0;
(**w_objs_hndl).dirty = FALSE;
/********** Allocate and initialize the print info record **********/
/* print_info_hndl = (THPrint)NewHandle(sizeof(TPrint));*/
/* if(print_info_hndl == NIL)*/
/* {*/
/* DisposeWindow(wPtr);*/
/* #ifdef powerc*/
/* StopAlert(OUT_OF_MEM, (UniversalProcPtr)NIL);*/
/* #else*/
/* StopAlert(OUT_OF_MEM, NIL);*/
/* #endif /* powerc »*/
/* return(NIL);*/
/* }*/
/* */
/* */
/* PrOpen();*/
/* printerDriverError=PrError();*/
/* PrintDefault( print_info_hndl );*/
/* if(printerDriverError)*/
/* {*/
/* (**print_info_hndl).prInfo.rPage.right = H_RPAGE_DEFAULT;*/
/* (**print_info_hndl).prInfo.rPage.bottom = V_RPAGE_DEFAULT;*/
/* }*/
/* PrClose();*/
/* */
/* (**w_objs_hndl).prInfoHndl = print_info_hndl;*/
/************* Clear out the list of objects-in-window ******************/
if(selector == 3) ;
else {
for(n = 0; n < MAX_OBJECTS; n++)
{
(**w_objs_hndl).object[n].type = NO_OBJ;
(**w_objs_hndl).object[n].selected = FALSE;
}
}
/************* Set up the vertical scrollbar **************************/
cntrl_hndl = GetNewControl (SCROLLBAR_ID, wPtr);
if(cntrl_hndl != NIL)
{
MoveControl (cntrl_hndl, wPtr->portRect.right - 15, -1);
SizeControl (cntrl_hndl, 16, wPtr->portRect.bottom - 13);
cntrl_max = (**w_objs_hndl).vDocLimit
- ((wPtr->portRect.bottom - 15)
- wPtr->portRect.top);
if(cntrl_max < 0) cntrl_max = 0;
SetCtlMax (cntrl_hndl, cntrl_max);
(**w_objs_hndl).myVCntrlHdl = cntrl_hndl;
//SetCRefCon ((**w_objs_hndl).myVCntrlHdl, (long)0);
}
/************* Set up the horizontal scrollbar **************************/
cntrl_hndl = GetNewControl (SCROLLBAR_ID, wPtr);
if(cntrl_hndl != NIL)
{
MoveControl (cntrl_hndl, -1, wPtr->portRect.bottom - 15);
SizeControl (cntrl_hndl, wPtr->portRect.right - 13, 16);
cntrl_max = (**w_objs_hndl).hDocLimit
- ((wPtr->portRect.right - 15)
- wPtr->portRect.left);
if(cntrl_max < 0) cntrl_max = 0;
SetCtlMax (cntrl_hndl, cntrl_max);
(**w_objs_hndl).myHCntrlHdl = cntrl_hndl;
SetCRefCon ((**w_objs_hndl).myHCntrlHdl, (long)0);
}
//if(selector == 3) GetPreyBkgrnd(wPtr);
return(wPtr);
} /* end of make_circle_window() */